package com.lujianfei.productprice.ui.order;

import android.os.Parcel;
import android.os.Parcelable;

import com.orm.SugarRecord;
import com.orm.dsl.Column;
import com.orm.dsl.Ignore;
import com.orm.dsl.Table;

import java.util.List;

@Table(name = "OrderEntity")
public class OrderEntity extends SugarRecord implements Parcelable {

    @Column(name = "totalPrice")
    private double totalPrice;

    @Column(name = "createTime")
    private long createTime;
    @Ignore
    private List<OrderDetailEntity> orderDetailEntityList;

    public OrderEntity() {
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public List<OrderDetailEntity> getOrderDetailEntityList() {
        return orderDetailEntityList;
    }

    public void setOrderDetailEntityList(List<OrderDetailEntity> orderDetailEntityList) {
        this.orderDetailEntityList = orderDetailEntityList;
    }

    protected OrderEntity(Parcel in) {
        totalPrice = in.readDouble();
        createTime = in.readLong();
        orderDetailEntityList = in.createTypedArrayList(OrderDetailEntity.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeDouble(totalPrice);
        dest.writeLong(createTime);
        dest.writeTypedList(orderDetailEntityList);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<OrderEntity> CREATOR = new Creator<OrderEntity>() {
        @Override
        public OrderEntity createFromParcel(Parcel in) {
            return new OrderEntity(in);
        }

        @Override
        public OrderEntity[] newArray(int size) {
            return new OrderEntity[size];
        }
    };
}
